package com.huawei.hms.auth.api.signin.internal;

import android.app.Activity;
import android.content.Context;
import com.huawei.hms.adapter.AvailableAdapter;
import com.huawei.hms.adapter.AvailableAdapter.AvailableCallBack;
import com.huawei.hms.support.log.HMSLog;

public class h {
    public static void a(Activity activity, AvailableCallBack availableCallBack) {
        HMSLog.i("HuaweiIdVersionCheck", "====== HMSSDK version: 30003300 ======");
        Context applicationContext = activity.getApplicationContext();
        int a = a();
        HMSLog.i("HuaweiIdVersionCheck", "check minVersion:" + a);
        AvailableAdapter availableAdapter = new AvailableAdapter(a);
        int isHuaweiMobileServicesAvailable = availableAdapter.isHuaweiMobileServicesAvailable(applicationContext);
        if (isHuaweiMobileServicesAvailable == 0) {
            availableCallBack.onComplete(isHuaweiMobileServicesAvailable);
        } else if (availableAdapter.isUserResolvableError(isHuaweiMobileServicesAvailable)) {
            a(activity, availableAdapter, availableCallBack);
        } else {
            availableCallBack.onComplete(isHuaweiMobileServicesAvailable);
        }
    }

    private static void a(Activity activity, AvailableAdapter availableAdapter, AvailableCallBack availableCallBack) {
        if (activity == null) {
            HMSLog.i("HuaweiIdVersionCheck", "null activity, could not start resolution intent");
        }
        availableAdapter.startResolution(activity, availableCallBack);
    }

    public static int a() {
        return 30000000;
    }
}
